<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/cart.css" />
<script language="javascript">
function printdiv(printpage)
{
var headstr = "<html><head><title></title></head><body>";
var footstr = "</body>";
var newstr = document.all.item(printpage).innerHTML;
var oldstr = document.body.innerHTML;
document.body.innerHTML = headstr+newstr+footstr;
window.print();
document.body.innerHTML = oldstr;
return false;
}
</script>
<?
$path = '../Mkart/';
include($path."common.php");


$ord_dt = substr($_POST['process_date'],0,4) . "年" .  substr($_POST['process_date'],4,2) . "月"  . substr($_POST['process_date'],6,2) . "日&nbsp;&nbsp;" .  substr($_POST['process_time'],0,2) . ":" .  substr($_POST['process_time'],2,2) . ":"  . substr($_POST['process_time'],4,2)  ;

if($_POST["succ"] == 1){

$oid = trim($_POST['od_sob']) ;
$process_date = $_POST['process_time'];
//===============================
include($path."order_mail.php");
include($path."mailsend.php");
//===============================
$sql_edit = "select * from  kart_order where order_id = '$oid' " ;
$result_edit = mysql_query($sql_edit);
$row_edit=mysql_fetch_object($result_edit);

$ord_invoice = $row_edit->order_invoice;						//訂單發票抬頭
$ord_invoiceno = $row_edit->order_invoiceno;						//訂單統一編號
$ord_stage = $row_edit->order_stage;						//分期期數
?>
<div id=div_print>
<table width=450 border=1 align=center>
<tr>
<td align=right colspan="2">米倉確認訂購單</td>

</tr>
<tr>
<td align=right>交易單號：</td>
<td align=left><?php echo $oid?></td>
</tr>
<tr>
<td align=right>刷卡金額：</td>
<td align=left><?php echo $_POST['amount']?></td>
</tr>
<?php 
if($_POST['stage']){
?>
<tr>
<td align=right>分期期數：</td>
<td align=left><?php echo $_POST['stage']?></td>
</tr>
<tr>
<td align=right>頭期金額：</td>
<td align=left><?php echo $_POST['stast']?></td>
</tr>
<tr>
<td align=right>各期金額：</td>
<td align=left><?php echo $_POST['staed']?></td>
</tr>
<?php
} 
?>

<tr>
<td align=right>處理時間：</td>
<td align=left><?php echo $ord_dt?></td>
</tr>
<?php
if($ord_invoice){ 
?>

<tr>
<td align=right>發票抬頭：</td>
<td align=left><?php echo $ord_invoice?></td>
</tr>
<?php
}
if($ord_invoiceno){ 
?>

<tr>
<td align=right>統一編號：</td>
<td align=left><?php echo $ord_invoiceno?></td>
</tr>
<?php
} 
?>

<tr>
<td align=right>商品明細：</td>
<td align=left>
<table width=100% border=1 align=center>
<td align=center>商品名稱</td>
<td align=center width=20%>數量</td>
<?php
$sql_item = "select * from  order_item where order_id = '$oid' order by order_id" ;
$result_item = mysql_query($sql_item);
while($row_item=mysql_fetch_object($result_item)){
$item_no = $row_item->item_id;											//商品編號
$item_amount = $row_item->item_amount;						//商品購買數量

$sql_pd = "select * from  product where id = '$item_no' " ;
$result_pd = mysql_query($sql_pd);
$row_pd = mysql_fetch_object($result_pd);
$pd_name = $row_pd->name;												//商品名稱 
?>

<tr>
<td align=left><?php echo $pd_name?></td>
<td align=right><?php echo $item_amount?></td>
</tr>
<?php
} 
?>

</table>
</td>
</tr>

<tr>
<td align=right>交易狀態：</td>
<td align=left>交易完成</td>
</tr>

</table>
</div>
<table width=450 border=0 align=center>
<tr>
<td align=right width=50%><input name=b_print type=button onClick="printdiv('div_print');" value="Print"></td>
<td align=left width=50%><input name=div_colse type=button value="關閉視窗" onclick="window.opener=null;window.close();"></td>
</tr>
</table>
<?php
} 
?>



